package com.hongxun.project.assets.iPoint.service;

import java.util.List;
import java.util.UUID;

import com.hongxun.common.utils.bean.BeanUtils;
import com.hongxun.project.assets.iBoxes.domain.IBoxes;
import com.hongxun.project.assets.pBoxes.domain.PBoxes;
import com.hongxun.project.assets.pPoint.domain.PPoint;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hongxun.project.assets.iPoint.mapper.IPointMapper;
import com.hongxun.project.assets.iPoint.domain.IPoint;
import com.hongxun.project.assets.iPoint.service.IIPointService;
import com.hongxun.common.utils.text.Convert;

/**
 * 地理走向图 服务层实现
 * 
 * @author hongxun
 * @date 2019-03-19
 */
@Service
public class IPointServiceImpl implements IIPointService 
{
	@Autowired
	private IPointMapper iPointMapper;

	/**
     * 查询地理走向图信息
     * 
     * @param id 地理走向图ID
     * @return 地理走向图信息
     */
    @Override
	public IPoint selectIPointById(String id)
	{
	    return iPointMapper.selectIPointById(id);
	}

	@Override
	public List<IPoint> selectlistIsPole(String byqId,String id,String poleId)
	{
		return iPointMapper.selectlistIsPole(byqId,id,poleId);
	}
	
	/**
     * 查询地理走向图列表
     * 
     * @param iPoint 地理走向图信息
     * @return 地理走向图集合
     */
	@Override
	public List<IPoint> selectIPointList(IPoint iPoint)
	{
	    return iPointMapper.selectIPointList(iPoint);
	}
	
    /**
     * 新增地理走向图
     * 
     * @param iPoint 地理走向图信息
     * @return 结果
     */
	@Override
	public int insertIPoint(IPoint iPoint)
	{
		iPoint.setId(UUID.randomUUID().toString());
	    return iPointMapper.insertIPoint(iPoint);
	}
	
	/**
     * 修改地理走向图
     * 
     * @param iPoint 地理走向图信息
     * @return 结果
     */
	@Override
	public int updateIPoint(IPoint iPoint)
	{
	    return iPointMapper.updateIPoint(iPoint);
	}

	/**
     * 删除地理走向图对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
	@Override
	public int deleteIPointByIds(String ids)
	{
		return iPointMapper.deleteIPointByIds(Convert.toStrArray(ids));
	}


	public void file(List<PPoint> pPoint) {
		for (PPoint p : pPoint) {
			if (p.getDatastate().equals("删除")) {
				deleteIPointByIds(p.getId());
			} else {
				IPoint i = new IPoint();
				BeanUtils.copyBeanProp(i, p);
				if (selectIPointById(p.getId()) != null) {
					updateIPoint(i);
				} else {
					iPointMapper.insertIPoint(i);
				}
			}
		}
	}


	@Override
	public List getCountForVoltage(String id){
		return getCountForVoltage(id);
	}

	@Override
	public Float totalLine(String id , String voltage){
		return iPointMapper.totalLine(id,voltage);
	}

	@Override
	public int selectCoutByPoleHeightOrCrossType(IPoint iPoint){
		return iPointMapper.selectCoutByPoleHeightOrCrossType(iPoint);
	}

}
